﻿using System;
using System.Web.UI.WebControls;

namespace ECommerce.Controls
{
	public partial class Register : BaseUserControl
	{
		protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
		{
			System.Web.Security.Roles.AddUserToRole(CreateUserWizard1.UserName, "customer");
		}

		protected void CreateUserWizard1_ContinueButtonClick(object sender, EventArgs e)
		{
			Server.Transfer("~/Customer/MyAccountHome.aspx");
		}

		protected void Page_PreRender(object sender, EventArgs e)
		{
			this.LRegisterTitle.Text = GetLocalResourceString("Register.Title");
			this.LRegisterTips.Text = GetLocalResourceString("Register.Tips");
			//if(!IsPostBack)
			//{
			//    this.Page.Title = GetLocalResourceString("Ecommerce.PageTitle.Register");
			//}
		}

		protected void CreateUserWizard1_PreRender(object sender, EventArgs e)
		{
			CreateUserWizard1.CreateUserButtonText = GetLocalResourceString("Register.CreateUserButton.Text");
		}

		protected void PasswordCompare_PreRender(object sender, EventArgs e)
		{
			var PasswordCompare = sender as CompareValidator;

			PasswordCompare.ErrorMessage = GetLocalResourceString("Register.ErrorMassage.ConfirmPasswordNotSameAsPassword");
		}

		protected void ContinueButton_PreRender(object sender, EventArgs e)
		{
			var ContinueButton = sender as Button;

			ContinueButton.Text = GetLocalResourceString("Register.ContinueButton.Text");
		}

		protected void RegularExpressionValidator_Email_PreRender(object sender, EventArgs e)
		{
			var RegularExpressionValidator_Email = sender as RegularExpressionValidator;

			RegularExpressionValidator_Email.ErrorMessage = GetLocalResourceString("Register.ErrorMassage.InvalidEmailFormat");
		}
	}
}